package cn.netswap.jeegorilla.framework.security.bean;

import java.awt.image.BufferedImage;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;

/**
 * 验证码的基类
 * @author lgw
 * @version 1.0
 * @date 2020/3/19 10:44
 */
public class ValidCode implements Serializable {
    /**
     * 验证码
     */
    private String code;
    /**
     * 验证码的有效时长
     */
    private Long validTimes;

    /**
     * 验证码开始的时间
     */
    Date date;

    public ValidCode(String code, Long validTimes, Date date) {
        this.code = code;
        this.validTimes = validTimes;
        this.date = date;
    }

    public ValidCode() {
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Long getValidTimes() {
        return validTimes;
    }

    public void setValidTimes(Long validTimes) {
        this.validTimes = validTimes;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public boolean isExpried() {
       long subtime =  System.currentTimeMillis() - date.getTime();
       if(subtime/1000 > validTimes){
           return true;
       }else{
           return false;
       }
    }
}
